<?php

declare (strict_types = 1);

namespace app\shop31\controller;
use \think\facade\View;
use \think\facade\Db;
use \think\facade\Request;

class Pinpai
{
    public function pin_pai(){
//        $post=Request::param();
//
//        View::assign($post);
////        echo "<pre>";
////        print_r($sql);ting'hao'de
////        echo "</pre>";
////助手函数  -  渲染视图
//        $where=[];
////品牌名称的模糊查询、品牌推荐的单选按钮查询（含全部和推荐不推荐）、品牌是否显示的复选框查询、有图无图复选框查询
//        $quanbu = \think\facade\Request::param('quanbu');
////         $butuijian = \think\facade\Request::param('butuijian'); //品牌不推荐按钮
//        $tuijian = \think\facade\Request::param('tuijian');     //品牌推荐按钮
//
////         $buxianshi = \think\facade\Request::param('buxianshi'); //不显示
//        $xianshi = \think\facade\Request::param('xianshi');     //显示
//
//        $youtu = \think\facade\Request::param('youtu');         //有图
////         $wutu = \think\facade\Request::param('wutu');           //无图
//
//        $name=\think\facade\Request::param('keywords');                //名称查询

        $where=[];


        $param=Request::param();

        View::assign($param);
        if (isset($param['quanbu']) && ($param['quanbu']) <> '') $where['quanbu']=$param['quanbu'];
//        if (isset($param['butuijian']) && !empty($param['butuijian'])) $where['butuijian']=$param['butuijian'];
        if (isset($param['tuijian']) && ($param['tuijian']) <> '' ) $where['tuijian']=$param['tuijian'];
//        if (isset($param['buxianshi']) && !empty($param['buxianshi'])) $where['buxianshi']=$param['buxianshi'];
        if (isset($param['xianshi']) && ($param['xianshi']) <> '') $where['xianshi']=$param['xianshi'];
        if (isset($param['youtu']) &&  !empty($param['youtu']) ) $where['youtu']=$param['youtu'];
//        if (isset($param['wutu']) && !empty($param['wutu'])) $where['wutu']=$param['wutu'];
        if (isset($param['keywords']) && !empty($param['keywords'])) $where['keywords']=$param['keywords'];

//        if (isset($quanbu) && $quanbu <> '')   $where[]=['brand_id','>=','0'];

//        if (isset($tuijian) && $tuijian <> '' && $tuijian == '0')   $where[]=['recommended','=',$tuijian];
//        if (isset($tuijian) && $tuijian <> '' && $tuijian == '1')   $where[]=['recommended','=',$tuijian];

//        if (isset($xianshi) && $xianshi <> ''  && $xianshi == '0')   $where[]=['if_show','=',$xianshi]; //不显示
//        if (isset($xianshi) && $xianshi <> ''  && $xianshi == '1')   $where[]=['if_show','=',$xianshi];    //显示


//        if (isset($youtu) && $youtu <> '' && $youtu == '1')   $where[]=['brand_logo','>','0'];
//        if (isset($youtu) && $youtu <> '' && $youtu == '0')   $where[]=['brand_logo','=',''];


//        if (isset($name) && $name <> '')   $where[]=['brand_name','like',"%{$name}%"];

//
//        $sql=\think\facade\Db::name('brand')
//            ->order('sort_order', 'asc')
//            ->where($where)
//            ->select()
//            ->toArray();


        $sql=\app\shop31\model\Brand::getBrand($where,$param);
        View::assign('sql',$sql);

        return view();
    }
}
